// stonewt1.cpp -- Stonewt class methods + conversion functions
#include <iostream>
using std::cout;
#include "48castForClass.hpp"

// construct Stonewt object from double value
StoneWeight::StoneWeight(double lbs)
{
    stone = int (lbs) / Lbs_per_stn;    // integer division
    pds_left = int (lbs) % Lbs_per_stn + lbs - int(lbs);
    pounds = lbs;
}

// construct Stonewt object from stone, double values
StoneWeight::StoneWeight(int stn, double lbs)
{
    stone = stn;
    pds_left = lbs;
    pounds =  stn * Lbs_per_stn +lbs;
}

StoneWeight::StoneWeight()          // default constructor, wt = 0
{
    stone = pounds = pds_left = 0;
}

StoneWeight::~StoneWeight()         // destructor
{
}

// show weight in stones
void StoneWeight::show_stn() const
{
    cout << stone << " stone, " << pds_left << " pounds\n";
}

// show weight in pounds
void StoneWeight::show_lbs() const
{
    cout << pounds << " pounds\n";
}

// conversion functions
StoneWeight::operator int() const
{
    return int (pounds + 0.5);
}

StoneWeight::operator double()const
{
    return pounds; 
}
